# 购物：
#         1.用户的账户里有钱
#         2.用户可推一个空的购物车进商场
#         3.开始购物，将自己想要的商品添加购物车
#         4.打印购物小条
money = int(input("money:"))
goods = ["苹果","香蕉","葡萄","矿泉水","牛奶","豆腐","火腿"]
goods_price = {'苹果': 5,'香蕉': 3,'葡萄': 4,'矿泉水': 2,'牛奶': 5,'豆腐': 3,'火腿': 5}
cart = []
while True:
    print("欢迎光临!当前商品有苹果,香蕉,葡萄,矿泉水,牛奶,豆腐,火腿")
    print("输入Q或q: 退出购物")
    my_goods = input("请输入您要购买的商品名：")
    if my_goods in goods:
        print("您要购买的商品是：",my_goods)
        print("单价是：",goods_price[my_goods])
        numbers = int(input("请输入购买数量："))
        if money >= goods_price[my_goods]*numbers:
            cart.append(my_goods)
            money -= goods_price[my_goods]*numbers
            print(f"恭喜，购买{my_goods}成功！您的卡余额还剩",money)
        else:
            print("穷鬼，钱不够！请到其他超市购买！")
            break
    else:
        print("没有这个商品，别瞎弄！")
        if my_goods == "q" or my_goods == "Q":
            print("欢迎下次光临！")
            break
sum = 0
print("购物小条如下：")
for my_goods in cart:
    print(f"商品:{my_goods},单价:{goods_price[my_goods]},购买数量:{numbers}")
    sum += goods_price[my_goods] * numbers
print("总价格:",sum)